POV-Ray : Newsgroups : povray.off-topic : Another stupid SQL query problem : Re: Another stupid SQL query problem Server Time
1 Oct 2024 05:21:42 EDT (-0400)
  Re: Another stupid SQL query problem  
From: Darren New
Date: 21 Apr 2008 20:03:05
Message: <480d2b39$1@news.povray.org>
Halbert wrote:
>> That's easy, then.
>>
>> select email, count(*) from logtable where '2008-...' < logtime and 
>> logtime < '2008...' group by email
>>
>> The "group by" (and possibly "with rollup" and "having" clauses) is what 
>> you need to read up on.
>>
>> If you need one of the IP addresses or other columns to come back, it's 
>> harder.
> 
> 
> In reality, I need to select based on DK (a company identifier,)the script 
> name and the date range but I think that it would be sufficient to return 
> with only the email and the count. 

The "group by" lets you select on anything. (I.e., the "where" clause 
can refer to any column, including joins with other tables etc.)  But 
everything you *return* has to either be mentioned in the "group by" 
clause or has to be a summary function (like count(), sum(), avg(), 
etc).  (I forget what those kinds of functions are called in SQL, but...)

-- 
   Darren New / San Diego, CA, USA (PST)
     "That's pretty. Where's that?"
          "It's the Age of Channelwood."
     "We should go there on vacation some time."


Post a reply to this message

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.